package com.music.list;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.music.R;
import com.music.mp3.Mp3;
import com.music.player.PlayerService;
import com.music.set.AboutActivity;
import com.music.set.LookLrcActivity;
import com.music.set.PatternActivity;

import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class SetMusicActivity extends ListActivity{
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.setmisc);
		HashMap<String, Object> set_map1=new HashMap<String, Object>();
		HashMap<String, Object> set_map2=new HashMap<String, Object>();
		HashMap<String, Object> set_map3=new HashMap<String, Object>();
		HashMap<String, Object> set_map4=new HashMap<String, Object>();
		set_map1.put("set_image", R.drawable.set_ms);
		set_map1.put("xtsz", "播放模式");
		set_map2.put("set_image", R.drawable.set_gc);
		set_map2.put("xtsz", "歌词显示");
		set_map3.put("set_image", R.drawable.set_gy);
		set_map3.put("xtsz", "关于");
		set_map4.put("set_image", R.drawable.set_icon);
		set_map4.put("xtsz", "安全退出");
		List<HashMap<String, Object>> list=new ArrayList<HashMap<String,Object>>();
		list.add(set_map1);
		list.add(set_map2);
		list.add(set_map3);
		list.add(set_map4);
		SimpleAdapter adapter=new SimpleAdapter
				(this, list, R.layout.setmusic_item,  new String[]{"set_image","xtsz"}, new int[]{R.id.set_image,R.id.xtsz});
		setListAdapter(adapter);
	}
	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		// TODO Auto-generated method stub
		super.onListItemClick(l, v, position, id);
		Log.i("index", position+"");
		if(position==0){
			Intent i=new Intent();
			i.setClass(SetMusicActivity.this, PatternActivity.class);
			startActivity(i);
		}else if(position==1){
			Intent i=new Intent();
			i.setClass(SetMusicActivity.this, LookLrcActivity.class);
			startActivity(i);
		}else if(position==2){
			Intent i=new Intent();
			i.setClass(SetMusicActivity.this, AboutActivity.class);
			startActivity(i);
		}else if(position==3){
			exitMp3();
		}
	}
	public void exitMp3(){
		Intent i=new Intent();
		i.setClass(this, PlayerService.class);
		stopService(i);
		 System.exit(0);
	}
}
